//登录区域
const left = document.querySelector('.left')
const right = document.querySelector('.right')
const left1 = document.querySelector('.left1')
const left2 = document.querySelector('.left2')
const right1 = document.querySelector('.right1')
const blue1 = document.querySelector('.blue1')
const blue2 = document.querySelector('.blue2')
left.addEventListener('click', function () {
  if (left.className.includes('active')) return
  left.classList.add('active')
  right.classList.remove('active')
  blue2.style.display = 'none'
  blue1.style.display = 'block'
  left1.style.display = 'block'
  left2.style.display = 'none'
})

right.addEventListener('click', function () {
  if (right.className.includes('active')) return
  right.classList.add('active')
  left.classList.remove('active')
  blue2.style.display = 'block'
  blue1.style.display = 'none'
  left1.style.display = 'none'
  left2.style.display = 'block'
})

// //登录模块校验
const btn = document.querySelector('.btn')
const tel = document.querySelector('.tel')
const verify1 = document.querySelector('.verify1')
const email = document.querySelector('.email')
const verify2 = document.querySelector('.verify2')
const telvalue = document.querySelector('.tel')
const reg1 = document.querySelector('.reg1')
const reg2 = document.querySelector('.reg2')
const reg3 = document.querySelector('.reg3')
const reg4 = document.querySelector('.reg4')
const form = document.querySelector('form')
let tels = null
let mas = null
let es = null
let pas = null
const telReg = /^[1][3,4,5,7,8,9][0-9]{9}$/  //手机号规则
const ma = /[0-9]{6}/  //验证码规则
const emails = /^([a-zA-Z\d])(\w|\-)+@[a-zA-Z\d]+\.[a-zA-Z]{2,4}$/ //邮箱在规则
const mima = /^[\w_-]{6,16}$/  //密码正则
form.addEventListener('submit', function (e) {
  e.preventDefault()
})
btn.addEventListener('click', function () {
  //手机号正则校验
  if (left1.style.display === '' || left1.style.display === 'block') {
    if (!telReg.test(tel.value)) {
      reg1.style.visibility = 'visible'
      tels = false
    } else {
      reg1.style.visibility = 'hidden'
      tels = true
    }
  }
  //验证码正则校验
  if (left1.style.display === '' || left1.style.display === 'block') {
    if (!ma.test(verify1.value)) {
      reg2.style.visibility = 'visible'
      mas = false
    } else {
      reg2.style.visibility = 'hidden'
      mas = true
    }
  }
  //邮箱校验
  if (left2.style.display === '' || left2.style.display === 'block') {
    if (!emails.test(email.value)) {
      reg3.style.visibility = 'visible'
      es = false
    } else {
      reg3.style.visibility = 'hidden'
      es = true
    }
  }
  //邮箱密码校验
  if (left2.style.display === '' || left2.style.display === 'block') {
    if (!mima.test(verify2.value)) {
      reg4.style.visibility = 'visible'
      pas = false
    } else {
      reg4.style.visibility = 'hidden'
      pas = true
    }

  }


  if (tels && mas || es && pas) {
    //跳转
    location.href = "../HTML/专业号平台2.html"
  }


})
